package com.boot.controller;

import com.boot.entity.Menu;
import com.boot.entity.User;
import com.boot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/home")
public class HomeController {

    @Autowired
    UserService userService;

    @GetMapping("/index")
    public String index(HttpSession session,Model model){
        User user = (User) session.getAttribute("user");

        //3、已经选中的菜单找到
        List<Menu> selectedMenus = userService.getMenusByUserId(user.getId());

        model.addAttribute("selectedMenus",selectedMenus);

        return "home/index";
    }

}
